/*****************************************Copyright(C)******************************************
******************************************* *********************************************
*------------------------------------------文件信息---------------------------------------------
* FileName          : RS485.h
* Author            : 张婷颖
* Version           : 1.0V
* Description       : 物理层使用RS485的相关协议
*----------------------------------------历史版本信息-------------------------------------------
* History           :
* Description       :
*-----------------------------------------------------------------------------------------------
***********************************************************************************************/
#ifndef SCHEME_RS485_H_
#define SCHEME_RS485_H_
#include "top_scheme.h"
#include "main.h"
#if RS485
/* Includes-----------------------------------------------------------------------------------*/
#if MODBUS_485
#include "modbus_master.h"
#endif  /*MODBUS_485*/

/* Private define------------------------------------------------------------------------------*/
#if MODBUS_485 == 1
#define MODBUS_485_ADDR 0x01                              //定义改端口的设备地址
#define COIL	 1                                            //用于云端配置服务修改COIL的读取地址及参数
#define REGISTER   1                                      //用于云端配置服务修改REG的读取地址及参数

#if COIL
#define SUM_COIL_CON 3
#define COIL_ADDR {0x01A5,0x13A6,0x1821}
#define COIL_NUM {88,3,1}
#endif  /*COIL*/

#if REGISTER
#define SUM_REG_CON 4
#define REG_ADDR {0x057A,0x0591,0x05E4,0x0640}
#define REG_NUM {5,1,4,4}
#endif  /*REGISTER*/


#endif  /*MODBUS_485*/
/* Private typedef----------------------------------------------------------------------------*/

/* Private macro------------------------------------------------------------------------------*/

/* Private variables--------------------------------------------------------------------------*/
#if MODBUS_485
extern INFO_COMBINATION m485_sum_info;
#endif /*MODBUS_485*/
/* Private function prototypes----------------------------------------------------------------*/

/* Private functions--------------------------------------------------------------------------*/
#if MODBUS_485
void RX_Analyse_info(uint8_t *p,uint8_t Len);                    //分析接收到的信息帧
void RX_Parse_Data(INFO_COMBINATION *m485_sum_info);             //主循环分别解析处理接收的数据
void M485_read(void);                                            //主循环MODBUS读取信息
#endif  /*MODBUS_485*/
#endif  /*485*/
#endif /* SCHEME_RS485_H_ */
